from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
# 实例化驱动
browser = webdriver.Chrome()

# 打开网页
browser.get("https://www.baidu.com/")

# 设置等待
browser.implicitly_wait(15)

# 输入内容
browser.find_element(By.ID,"kw").send_keys("秦忠诚")

# 点击搜索按钮
browser.find_element(By.ID,"su").click()


# 操作滚动条  ，通过JS控制的
win1 = "window.scrollBy(0,500)"     #   Y轴向下500像素
win2 = "window.scrollBy(0,300)"     #   Y轴向下500像素
win3 = "window.scrollBy(0,200)"     #   Y轴向下200像素
win4 = "window.scrollBy(0,-700)"     #   Y轴向上700像素
win5 = "window.scrollBy(500,0)"     #   X轴向右500像素
win6 = "window.scrollBy(-300,0)"     #   X轴向左300像素


sleep(1)
browser.execute_script(win1)
sleep(1)
browser.execute_script(win2)
sleep(1)
browser.execute_script(win3)
sleep(1)
browser.execute_script(win4)
sleep(1)
browser.execute_script(win5)
sleep(1)
browser.execute_script(win6)
sleep(10)

